;Copyright (C) 2010 Salil Bhagurkar

;This file is part of k3

;k3 is free software: you can redistribute it and/or modify
;it under the terms of the GNU Lesser General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.

;k3 is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU Lesser General Public License for more details.

;You should have received a copy of the GNU Lesser General Public License
;along with k3.  If not, see <http://www.gnu.org/licenses/>.

[bits 32]
[segment .text]

extern setvect

global set_intel_efa
set_intel_efa:
mov ecx,ex0h
mov edx,0
call setvect
mov ecx,ex1h
mov edx,1
call setvect
mov ecx,ex2h
mov edx,2
call setvect
mov ecx,ex3h
mov edx,3
call setvect
mov ecx,ex4h
mov edx,4
call setvect
mov ecx,ex5h
mov edx,5
call setvect
mov ecx,ex6h
mov edx,6
call setvect
mov ecx,ex7h
mov edx,7
call setvect
mov ecx,ex8h
mov edx,8
call setvect
mov ecx,ex9h
mov edx,9
call setvect
mov ecx,ex10h
mov edx,10
call setvect
mov ecx,ex11h
mov edx,11
call setvect
mov ecx,ex12h
mov edx,12
call setvect
mov ecx,ex13h
mov edx,13
call setvect
mov ecx,ex14h
mov edx,14
call setvect
mov ecx,ex15h
mov edx,15
call setvect
mov ecx,ex16h
mov edx,16
call setvect
mov ecx,ex17h
mov edx,17
call setvect
mov ecx,ex18h
mov edx,18
call setvect
ret

;We do a cli immediately to prevent further exceptions due to any sort of preemption

%macro exception_handler 1
	extern __ex%1
	ex%1h:
	cli
	call __ex%1
	jmp $
%endmacro

exception_handler 0
exception_handler 1
exception_handler 2
exception_handler 3
exception_handler 4
exception_handler 5
exception_handler 6
exception_handler 7
exception_handler 8
exception_handler 9
exception_handler 10
exception_handler 11
exception_handler 12
exception_handler 13
exception_handler 14
exception_handler 15
exception_handler 16
exception_handler 17
exception_handler 18
